<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:body>
	<ui:composition template="/pages/protected/admin/template.xhtml">
		<ui:define name='templatemo_content'>
			<!-- Cabeçalho  -->
			<h2>
				Componente Curriculares
				<h:form id="btnNovo">
					<p:commandButton value="Novo" icon="ui-icon-plus"
						onclick="dlgNovo.show();" type="button" />
				</h:form>
			</h2>

			<!-- Lista -->
			<h:form id="listaCompCurrs">
				<p:dataTable id="tbCompCurrs" widgetVar="tbCompCurrs" var="comp"
					value="#{compCurrMB.compCurrs}" paginator="true" rows="10"
					paginatorPosition="bottom"
					paginatorTemplate="{PageLinks} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15"
					emptyMessage="Nenhuma componente foi encontrada.">

					<p:column headerText="Nome" filterBy="#{comp.nome}"
						filterMatchMode="contains">
						<h:outputText value="#{comp.nome}" />
					</p:column>
					
					<p:column headerText="Professor" filterBy="#{comp.professor.nome}"
						filterMatchMode="contains">
						<h:outputText value="#{comp.professor.nome}" />
					</p:column>

					<p:column headerText="Inicio" filterBy="#{comp.dtInicio}"
						filterMatchMode="contains">
						<h:outputText value="#{comp.dtInicio}" />
					</p:column>
					
					<p:column headerText="Fim" filterBy="#{comp.dtFim}"
						filterMatchMode="contains">
						<h:outputText value="#{comp.dtFim}" />
					</p:column>


					<!-- Botoes de Acoes -->
					<p:column style="width:4%">
						<p:commandButton id="btnEditar" icon="ui-icon-pencil"
							oncomplete="dlgEdit.show()" update=":editCompCurr">
							<f:setPropertyActionListener value="#{comp}"
								target="#{compCurrMB.selectedCompCurr}" />
						</p:commandButton>
						<p:tooltip for="btnEditar" value="Editar" showEffect="fade"
							hideEffect="fade" />

						<p:commandButton id="btnDeletar" icon="ui-icon-trash"
							title="Selecionar componente"
							action="#{compCurrMB.doRemover(comp)}"
							update=":listaCompCurrs">
						</p:commandButton>
						<p:tooltip for="btnDeletar" value="Deletar" showEffect="fade"
							hideEffect="fade" />
					</p:column>
				</p:dataTable>
			</h:form>

			<!-- Editar  -->
			<p:dialog id="editDialog" header="Edite Componente"
				widgetVar="dlgEdit" modal="true" resizable="false" height= "430px">
				<h:form id="editCompCurr">
					<p:messages />
					<p:wizard widgetVar="wizEdit"
						flowListener="#{compCurrMB.onFlowProcess}">

						<p:tab id="passo1" title="Passo 1">

							<h:panelGrid columns="2" style="min-height: 350px;">
								<h:outputLabel for="eNome" value="Nome:" />
								<p:inputText id="eNome"
									value="#{compCurrMB.selectedCompCurr.nome}" label="Nome">
									<f:validateLength minimum="2" />
								</p:inputText>

								<h:outputLabel for="eCreditos" value="Creditos:" />
								<p:inputText id="eCreditos"
									value="#{compCurrMB.selectedCompCurr.creditos}"
									label="Creditos">

								</p:inputText>

								<h:outputLabel for="eTipoComp" value="Tipo Componente:" />
								<p:selectOneMenu id="eTipoComp" required="true"
									value="#{compCurrMB.selectedCompCurr.tipoCompomente}"
									label="Tipo Componente">
									<f:selectItems value="#{compCurrMB.tipos}" />
								</p:selectOneMenu>

								<h:outputLabel for="eformaPart" value="Forma Participacao:" />
								<p:selectOneMenu id="eformaPart" required="true"
									value="#{compCurrMB.selectedCompCurr.formaParticipacao}"
									label="Forma Participacao">
									<f:selectItems value="#{compCurrMB.formas}" />
								</p:selectOneMenu>

								<h:outputLabel for="eLocal" value="Local:" />
								<p:inputText id="eLocal"
									value="#{compCurrMB.selectedCompCurr.local}" label="Local">
								</p:inputText>

								<h:outputLabel for="eNumVagas" value="Numero Vagas:" />
								<p:inputText id="eNumVagas"
									value="#{compCurrMB.selectedCompCurr.numVagas}"
									label="eNumVagas">
								</p:inputText>

								<h:outputLabel for="eDia" value="Dia(s):" />
								<p:inputText id="eDia"
									value="#{compCurrMB.selectedCompCurr.dia}" label="eDia">
								</p:inputText>

								<h:outputLabel for="eHorario" value="Horario:" />
								<p:inputText id="eHorario"
									value="#{compCurrMB.selectedCompCurr.horario}" label="eDia">
								</p:inputText>

								<h:outputLabel for="eDtInicio" value="Inicio:" />
								<p:calendar id="eDtInicio"
									value="#{compCurrMB.selectedCompCurr.dtInicio}" label="eDia"
									showButtonPanel="true" />


								<h:outputLabel for="eDtFim" value="Fim:" />
								<p:calendar id="eDtFim"
									value="#{compCurrMB.selectedCompCurr.dtFim}" label="eFim"
									showButtonPanel="true" />

								<h:outputLabel for="eDescricao" value="Descricao:" />
								<p:inputTextarea id="eDescricao" rows="3" cols="37"
									value="#{compCurrMB.selectedCompCurr.descricao}" label="eFim" />
							</h:panelGrid>
						</p:tab>

						<p:tab id="passo2" title="Passo 2">
						<h:panelGrid cols="1" style="min-height: 350px;">
							<p:dataTable id="tbProfesores" var="prof" paginator="true"
								rows="10" paginatorPosition="top"
								value="#{compCurrMB.professores}" rowKey="#{prof.id}"
								selection="#{compCurrMB.selectedCompCurr.professor}">

								<p:column selectionMode="single" />

								<p:column headerText="Matricula" filterBy="#{prof.matricula}"
									filterMatchMode="contains">
									<h:outputText value="#{prof.matricula}" />
								</p:column>

								<p:column headerText="Nome" filterBy="#{prof.nome}"
									filterMatchMode="contains">
									<h:outputText value="#{prof.nome}" />
								</p:column>
							</p:dataTable>
							</h:panelGrid>
						</p:tab>

						<p:tab id="passo3" title="Passo 3">

							<h:panelGrid columns="2" style="min-height: 350px;">
								<h:outputLabel for="eEmenta" value="Ementa:" />
								<p:inputTextarea id="eEmenta" rows="6" cols="33"
									value="#{compCurrMB.selectedCompCurr.ementa}" label="eEmenta" />
								<h:outputLabel for="eReferencias" value="Referencias:" />
								<p:inputTextarea id="eReferencias" rows="6" cols="33"
									value="#{compCurrMB.selectedCompCurr.referencias}"
									label="eReferencias" />
							</h:panelGrid>
						</p:tab>
						<p:tab id="confirm" title="Confirma">
							<p:panel header="Confirmation" style="min-height: 350px;">
								<h:panelGrid id="confirmation" columns="6">
								</h:panelGrid>
								<p:commandButton value="Salvar" icon="ui-icon-check"
									update=":editCompCurr :listaCompCurrs"
									actionListener="#{compCurrMB.doAlterar}" />
								<p:button value="Cancelar" icon="ui-icon-closethick"
									immediate="true" update=":editCompCurr :listaCompCurrs"
									process="@this" oncomplete="dlgEdit.hide()" />
							</p:panel>
						</p:tab>
					</p:wizard>
				</h:form>
			</p:dialog>


			<!-- Novo  -->
			<p:dialog id="novoDialog" header="Nova Componente"
				widgetVar="dlgNovo" modal="true" height="auto" resizable="false">
				<h:form id="novaCompCurr">
					<p:messages />
					<p:wizard widgetVar="wizNovo"
						flowListener="#{compCurrMB.onFlowProcess}">

						<p:tab id="passo1" title="Passo 1">

							<h:panelGrid columns="2">
								<h:outputLabel for="nNome" value="Nome:" />
								<p:inputText id="nNome"
									value="#{compCurrMB.compCurr.nome}" label="Nome">
									<f:validateLength minimum="2" />
								</p:inputText>

								<h:outputLabel for="nCreditos" value="Creditos:" />
								<p:inputText id="nCreditos"
									value="#{compCurrMB.compCurr.creditos}"
									label="Creditos">
								</p:inputText>

								<h:outputLabel for="nTipoComp" value="Tipo Componente:" />
								<p:selectOneMenu id="nTipoComp" required="true"
									value="#{compCurrMB.compCurr.tipoCompomente}"
									label="Tipo Componente">
									<f:selectItems value="#{compCurrMB.tipos}" />
								</p:selectOneMenu>

								<h:outputLabel for="nformaPart" value="Forma Participacao:" />
								<p:selectOneMenu id="nformaPart" required="true"
									value="#{compCurrMB.compCurr.formaParticipacao}"
									label="Forma Participacao">
									<f:selectItems value="#{compCurrMB.formas}" />
								</p:selectOneMenu>

								<h:outputLabel for="nLocal" value="Local:" />
								<p:inputText id="nLocal"
									value="#{compCurrMB.compCurr.local}" label="Local">
								</p:inputText>

								<h:outputLabel for="nNumVagas" value="Numero Vagas:" />
								<p:inputText id="nNumVagas"
									value="#{compCurrMB.compCurr.numVagas}"
									label="Num Vagas">
								</p:inputText>

								<h:outputLabel for="nDia" value="Dia(s):" />
								<p:inputText id="nDia"
									value="#{compCurrMB.compCurr.dia}" label="Dia">
								</p:inputText>

								<h:outputLabel for="nHorario" value="Horario:" />
								<p:inputText id="nHorario"
									value="#{compCurrMB.compCurr.horario}" label="Horario">
								</p:inputText>

								<h:outputLabel for="nDtInicio" value="Inicio:" />
								<p:calendar id="nDtInicio"
									value="#{compCurrMB.compCurr.dtInicio}" label="Inicio"
									showButtonPanel="true" />

								<h:outputLabel for="nDtFim" value="Fim:" />
								<p:calendar id="nDtFim"
									value="#{compCurrMB.compCurr.dtFim}" label="Fim"
									showButtonPanel="true" />

								<h:outputLabel for="nDescricao" value="Descricao:" />
								<p:inputTextarea id="nDescricao" rows="6" cols="33"
									value="#{compCurrMB.compCurr.descricao}" label="Descricao" />
							</h:panelGrid>
						</p:tab>

						<p:tab id="passo2" title="Passo 2">
							<p:dataTable id="tbProfesoresNovo" var="prof" paginator="true"
								rows="10" paginatorPosition="top"
								value="#{compCurrMB.professores}" rowKey="#{prof.id}"
								selection="#{compCurrMB.compCurr.professor}">

								<p:column selectionMode="single" />

								<p:column headerText="Matricula" filterBy="#{prof.matricula}"
									filterMatchMode="contains">
									<h:outputText value="#{prof.matricula}" />
								</p:column>

								<p:column headerText="Nome" filterBy="#{prof.nome}"
									filterMatchMode="contains">
									<h:outputText value="#{prof.nome}" />
								</p:column>
							</p:dataTable>
						</p:tab>

						<p:tab id="passo3" title="Passo 3">

							<h:panelGrid columns="2">
								<h:outputLabel for="nEmenta" value="Ementa:" />
								<p:inputTextarea id="nEmenta" rows="6" cols="33"
									value="#{compCurrMB.compCurr.ementa}" label="Ementa" />
								
								<h:outputLabel for="nReferencias" value="Referencias:" />
								<p:inputTextarea id="nReferencias" rows="6" cols="33"
									value="#{compCurrMB.compCurr.referencias}"
									label="Referencias" />
							</h:panelGrid>
						</p:tab>
						<p:tab id="confirm" title="Confirma">
							<p:panel header="Confirmation">
								<h:panelGrid id="confirmation" columns="6">
								</h:panelGrid>

								<p:commandButton value="Salvar" icon="ui-icon-check"
									update=":novaCompCurr :listaCompCurrs"
									actionListener="#{compCurrMB.doInserir}" />
								<p:button value="Cancelar" icon="ui-icon-closethick"
									immediate="true" update=":novaCompCurr :listaCompCurrs"
									process="@this" oncomplete="dlgNovo.hide()" />
							</p:panel>
						</p:tab>
					</p:wizard>
				</h:form>
			</p:dialog>
		</ui:define>
	</ui:composition>
</h:body>
</html>